//
//  YBMYTowViewController.m
//  GoodBuy
//
//  Created by Cyber on 15/5/22.
//  Copyright (c) 2015年 GoodBuy. All rights reserved.
//

#import "YBMYTowViewController.h"


@interface YBMYTowViewController ()

@end

@implementation YBMYTowViewController

-(void)dealloc {
    [_tableView release];
    [super dealloc];
}
- (void)viewWillAppear:(BOOL)animated {
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tableView = [[UITableView alloc]initWithFrame:[[UIScreen mainScreen]bounds] style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource =self;
    [self.view addSubview:_tableView];
    [_tableView release];
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdrntifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdrntifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdrntifier];
        cell.textLabel.center = CGPointMake(110, 10);
        if (indexPath.row == 0) {
            cell.textLabel.text = @"国内购物";
        }
        if (indexPath.row == 1) {
            cell.textLabel.text = @"全球购物";
        }
        if (indexPath.row == 2) {
            cell.textLabel.text = @"购物新闻";
        }
        if (indexPath.row == 3) {
            cell.textLabel.text = @"清空收藏";
        }
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    YBThreeViewController *three = [[YBThreeViewController alloc]init];
    YBFourViewController *Four = [[YBFourViewController alloc]init];
    YBFiveViewController *five = [[YBFiveViewController alloc] init];
    if (indexPath.row == 0) {
        NSLog(@"222229");
        [[ChinaDCollectHandle shareChinaHandle]openDB];
        five.allArray = [[ChinaDCollectHandle shareChinaHandle]selectChina];
        self.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:five animated:YES];
        self.hidesBottomBarWhenPushed = NO;
    }
    else if (indexPath.row == 1) {
        NSLog(@"999");
        [[ForeignCollectHandle shareInstance]openMc];
        Four.allArray = [[ForeignCollectHandle shareInstance]selectAllForeign];
        self.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:Four animated:YES];
        self.hidesBottomBarWhenPushed = NO;
        
    }
    else if (indexPath.row == 2) {
        NSLog(@"asdf");
        [[NewsCollectHandle shareNewsHandle]openMC];
        three.allArray = [[NewsCollectHandle shareNewsHandle]selectAllNews];
        self.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:three animated:YES];
        self.hidesBottomBarWhenPushed = NO;
    }
    else if (indexPath.row == 3) {
        [[NewsCollectHandle shareNewsHandle] openMC];
        [[NewsCollectHandle shareNewsHandle] dropTable];
        [[ForeignCollectHandle shareInstance] openMc];
        [[ForeignCollectHandle shareInstance] dropTable];
        [[ChinaDCollectHandle shareChinaHandle] openDB];
        [[ChinaDCollectHandle shareChinaHandle] dropTable];
        NSLog(@"123");
    }
}

//-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    if (indexPath.row == 0) {
//        UITableViewCell *cell0 = [[UITableViewCell alloc]initWithFrame:CGRectMake(0, 0, kWidth, 50)];
//        return cell0;
//        
//    }
//    return 0;
//}



-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
